package com.sgcc.ln.pmos.e_ln_home.activity;

import android.view.View;

import com.alibaba.android.arouter.facade.annotation.Route;
import com.alibaba.android.arouter.launcher.ARouter;
import com.chad.library.adapter.base.BaseQuickAdapter;
import com.sgcc.pmos.nativesdk.R;
import com.sgcc.ln.pmos.arouter.home.HomeArouterPath;
import com.sgcc.ln.pmos.common.base.MvpBaseRecycleActivity;
import com.sgcc.ln.pmos.e_ln_home.adapter.PoliciesRegulationsAdapter;
import com.sgcc.ln.pmos.e_ln_home.bean.DynamicBean;
import com.sgcc.ln.pmos.e_ln_home.bean.DynamicNetBean;
import com.sgcc.ln.pmos.e_ln_home.contract.PoliciesRegulationsContract;
import com.sgcc.ln.pmos.e_ln_home.presenter.PoliciesRegulationsPresenter;

import java.util.List;

/**
 * 市场动态
 */
@Route(path = HomeArouterPath.HOME_MARKETDYNAMIC)
public class MarketDynamicActivity extends MvpBaseRecycleActivity<DynamicNetBean.DataDTO.ListDTO, PoliciesRegulationsPresenter> implements PoliciesRegulationsContract.View {

    private PoliciesRegulationsAdapter mPoliciesRegulationsAdapter;

    @Override
    public void querySuccess(List<DynamicBean> list) {
//        loadSuccess(false, list);
    }

    @Override
    public void queryNetDataSuccess(DynamicNetBean list) {
        loadSuccess(false, list.getData().getList());
    }

    @Override
    protected PoliciesRegulationsPresenter createPresenter() {
        return new PoliciesRegulationsPresenter();
    }

    @Override
    public BaseQuickAdapter getAdapter() {
        mPoliciesRegulationsAdapter = new PoliciesRegulationsAdapter(mContext);
        mPoliciesRegulationsAdapter.setOnItemClickListener(new PoliciesRegulationsAdapter.OnItemClickListener() {
            @Override
            public void itemClickListener(int position, DynamicNetBean.DataDTO.ListDTO bean) {
                ARouter.getInstance()
                        .build(HomeArouterPath.HOME_PUBLICLAWSDYNAMICINFO)
                        .withSerializable("mDynamicBean", bean)
                        .withString("from", "2")
                        .navigation();
            }
        });
        return mPoliciesRegulationsAdapter;
    }

    @Override
    public void getDataRequest(int listSize, boolean isloading) {
        super.getDataRequest(listSize, isloading);
        mPresenter.getListData(listSize);
    }

    @Override
    public String getTitleText() {
        return "市场动态";
    }

    @Override
    protected void initViews() {
        super.initViews();
        title_bar.setRightIcon(R.mipmap.go_main, new View.OnClickListener() {
            @Override
            public void onClick(View view) {
                goMainActivity();
            }
        });
    }
}
